
//反应状态
namespace Enemy
{
    public class ReactState : IState
    {
        public ReactState(FSM manager)
        {
            this.manager = manager;
            this.parameter = manager.parameter;
        }

        public override void OnEnter()
        {
            parameter.animator.Play("React");
        }

        public override void OnUpdate()
        {
            // 如果被击中标志为true，转换到受击状态
            if (parameter.isHurt)
            {
                manager.TransitionState(StateType.Hit);
            }

            // 如果动画播放进度超过95%，转换到追逐状态
            if (parameter.animatorStateInfo.normalizedTime >= 0.95f)
            {
                manager.TransitionState(StateType.Chase);
            }
        }

        public override void OnFixedUpdate() { }

        public override void OnExit() { }
    }
}
